from google.appengine.ext.webapp import template

from views.base import ViewBase
from models import Note

class ReleaseNotes(ViewBase):
    context = {}

    def show_notes(self, version):
        if version == 'list':
            return self._list()

        self.context['note'] = Note.gql("WHERE version = :version", version=version).get()
        return template.render(self.get_template('notes/index.html'), self.context)

    def _list(self):
        nq = Note.gql("WHERE outdated=False")
        self.context['notes'] = nq.fetch(nq.count())

        return template.render(self.get_template('notes/list.html'), self.context)